package com.shou.dao;

import org.apache.ibatis.annotations.*;

import com.shou.auth.model.User;

import java.util.List;

@Mapper
public interface UserMapper {

    @Select("SELECT * FROM users")
    List<User> getAllUsers();

    @Select("SELECT * FROM users WHERE userId = #{userId}")
    User getUserById(String userId);

    @Insert("INSERT INTO users (userId, name, userCode, sex, dept, pwd, loginName, idCard, homeAddress, postCode, email, mobilePhone) " +
            "VALUES (#{userId}, #{name}, #{userCode}, #{sex}, #{dept}, #{pwd}, #{loginName}, #{idCard}, #{homeAddress}, #{postCode}, #{email}, #{mobilePhone})")
    void insertUser(User user);

    @Update("UPDATE users SET name=#{name}, userCode=#{userCode}, sex=#{sex}, dept=#{dept}, pwd=#{pwd}, loginName=#{loginName}, idCard=#{idCard}, homeAddress=#{homeAddress}, postCode=#{postCode}, email=#{email}, mobilePhone=#{mobilePhone} WHERE userId=#{userId}")
    void updateUser(User user);

    @Delete("DELETE FROM users WHERE userId=#{userId}")
    void deleteUser(String userId);
}